package com.example.administrator.szb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.AskBean;

import java.util.List;


/**
 * Created by stone on 2018/1/5.
 */

public class UCenterAskAdapter extends android.widget.BaseAdapter{
    private List list;
    private Context context;
    LayoutInflater inflater;
    public UCenterAskAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(this.context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public AskBean getItem(int position) {
        return (AskBean)list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = inflater.inflate(R.layout.item_shocang_wd,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.title.setText(getItem(position).getTitle());
        holder.sc.setText(getItem(position).getCollect_count()+"收藏");
        holder.huifu.setText(getItem(position).getAnswer_count()+"回复");
        holder.time.setText(getItem(position).getCreate_time());
        return convertView;
    }
    class ViewHolder{
        View my_check_box;
        LinearLayout checkBox_ll;
        TextView title,sc,huifu,time;
        public ViewHolder(View view){

            my_check_box = view.findViewById(R.id.my_check_box);
            checkBox_ll = view.findViewById(R.id.checkBox_ll);
            title = view.findViewById(R.id.title);
            sc = view.findViewById(R.id.huifu);
            huifu = view.findViewById(R.id.huifu);
            time = view.findViewById(R.id.time);
        }
    }
}
